#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main()
{
    int n = 0;
    scanf("%d", &n);
    int str1[17] = { 7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2 };
    char str2[11] = { 1 ,0 ,88 ,9, 8, 7, 6, 5, 4, 3, 2 };
    int count = 0;
    while (n--)
    {
        char arr[18];
        scanf("%s", arr);
        int sum = 0;
        for (int i = 0; i < 17; i++)
        {
            sum += (arr[i] - '0') * str1[i];
        }
        int num = sum % 11;
        int k = arr[17] - '0';
        if (k != str2[num])
        {
            count++;
            for (int i = 0; i < 18; i++)
            {
                printf("%c", arr[i]);
            }
            printf("\n");
        }
    }
    if (count == 0)
        printf("All passed\n");
    return 0;
}